package com.junqi.msg.enums;

import com.junqi.msg.entity.WSBaseReq;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * Description: 后端推送消息类型枚举
 */
@AllArgsConstructor
@Getter
public enum WSRespTypeEnum {

    MESSAGE(1, "你有新的消息要获取", WSBaseReq.class),
    CHAT_MESSAGE(2, "推送消息", WSBaseReq.class),
    ROOM_COUNT(3, "查询直播间人数", WSBaseReq.class),
//    INVALIDATE_TOKEN(6, "使前端的token失效，意味着前端需要重新登录", null),
//    BLACK(7, "拉黑用户", WSBlack.class),
//    MARK(8, "消息标记", WSMsgMark.class),
//    RECALL(9, "消息撤回", WSMsgRecall.class),
//    APPLY(10, "好友申请", WSFriendApply.class),
//    MEMBER_CHANGE(11, "成员变动", WSMemberChange.class),
    ;

    private final Integer type;
    private final String desc;
    private final Class dataClass;

    private static Map<Integer, WSRespTypeEnum> cache;

    static {
        cache = Arrays.stream(WSRespTypeEnum.values()).collect(Collectors.toMap(WSRespTypeEnum::getType, Function.identity()));
    }

    public static WSRespTypeEnum of(Integer type) {
        return cache.get(type);
    }
}
